Conditions | 3 |
Total Lines | 18 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { CommandHandler } from '@nestjs/cqrs'; |
||
16 | |||
17 | public async execute(command: UpdateTaskCommand): Promise<void> { |
||
18 | const { id, name } = command; |
||
19 | |||
20 | const task = await this.taskRepository.findOneById(id); |
||
21 | if (!task) { |
||
22 | throw new TaskNotFoundException(); |
||
23 | } |
||
24 | |||
25 | if ( |
||
26 | name !== task.getName() && |
||
27 | true === (await this.isTaskAlreadyExist.isSatisfiedBy(name)) |
||
28 | ) { |
||
29 | throw new TaskAlreadyExistException(); |
||
30 | } |
||
31 | |||
32 | task.updateName(name); |
||
33 | await this.taskRepository.save(task); |
||
34 | } |
||
36 |